<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style type="text/css">
body{
margin: 0;
background-image: url("bg1.jpg");
}
img{
/* 设置绝对定位 */
position: absolute;
width: 60px;
height: 60px;
}
</style>
</head>
<body>

  <script type="text/javascript" src="../js/jquery-1.4.2.js"></script>
  <script type="text/javascript">
  		//获取窗口的宽和高
  		var w=$(window).width();
  		var h=$(window).height();
  		//200px  100px
  		$("body").css("background-size",w+"px "+h+"px");
  		//窗口尺寸改变事件
  		onresize=function(){
  		//获取窗口的宽和高
  	  		 w=$(window).width();
  	  		 h=$(window).height();
  	  		//200px  100px
  	  		$("body").css("background-size",w+"px "+h+"px");
  		}
  		
  		//开启定时器添加僵尸图片
  		setInterval(function(){
  			//设置僵尸图片
  			var img=$("<img src='zomb0.png'>");
  			//设置僵尸位置
  			var top=parseInt(Math.random()*(h-60));
  			img.css({"left":w+"px","top":top+"px"});
  			$("body").append(img);
  		},100);
  		
  		//开启移动僵尸的定时器
  		setInterval(function(){
  			//得到所有僵尸图片并遍历
  			$("img").each(function(){
  				//得到原来的left值
  				var oldLeft=parseInt($(this).css("left"));
  				oldLeft-=2;
  				//把变小的值再放回去
  				$(this).css("left",oldLeft+"px")
  			});
  		},10);
		</script>
</body>
</html>